'use strict';
//1.正确使用egg搭建后台服务（10分）
const Service = require('egg').Service;

class loginService extends Service {
    async getUpdata(obj) {
        return await this.app.mysql.update('list',obj);
    }
    async create(obj) {
        return await this.app.mysql.insert('list',obj);
    }
    async destroy(obj) {
        return await this.app.mysql.delete('list',obj);
    }
    async index(page,pagesize,search) {
        let stateindex = (page-1)*pagesize
        let total = await this.app.mysql.query(`select count(*) from list where comName like '%${search}%'`);
        let res = await this.app.mysql.query(`select * from list where comName like '%${search}%' limit ${stateindex},${pagesize}`)
        return {
            total:total[0]["count(*)"],
            data:res
        }
    }
}

module.exports = loginService;
